package com.foreveross.fetl.core.domain.task.repository.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.foreveross.fetl.common.jpa.EntityOracleHibernateRepository;
import com.foreveross.fetl.core.domain.task.SourceEntity;
import com.foreveross.fetl.core.domain.task.repository.SourceEntityRepository;

@Repository("aourceEntityRepository")
public class SourceEntityRepositoryImpl extends EntityOracleHibernateRepository
		implements SourceEntityRepository {

	//@Transactional
	@Override
	public List<SourceEntity> findSourceEntityByType(String type) {
		//return super.find(QuerySettings.create(SourceEntity.class).eq("webTyle", type));
//		String sql = "SELECT t.ID AS id,t.NAME AS name,"
//				+ "t.WEB_TYLE AS webType,t.HBASE_KEY AS hbaseKey, t.CARRIER_KEY as carrierKey ,"
//				+ "t.SHORT_NAME AS shortName FROM"
//				+ " fdc_source  t WHERE t.WEB_TYLE = ?";
//		return DatabaseBeanUtils.getBeanList(sql, SourceEntity.class,
//				new Object[] { type });
		String sql = " select s from SourceEntity s where s.webTyle=? ";
		return super.queryResult(sql, new Object[]{type});
	}

	@Override
	public List<SourceEntity> findByHbaseKey(String channel) {
		String sql = " select s from SourceEntity s where s.hbaseKey=? ";
		return super.queryResult(sql, new Object[]{channel});
	}

	@Override
	public List<SourceEntity> findlessCreateTime(Date createTime) {
		String sql = " select s from SourceEntity s where s.createTime<=? ";
		return super.queryResult(sql, new Object[]{createTime});
	}

}
